#include <ctype.h>
#include<iostream>
using namespace std;
class Solution {
public:
    int lengthOfLastWord(string s) {
        int index =s.size()-1;
        while(isspace(s[index]))
        {
            index--;
        }
        int worldlth=0;
        while(index>=0&&!isspace(s[index]))
        {
            worldlth++;
            index--;
        }
        return worldlth;
    }
};